── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
✖ dplyr::filter() masks plotly::filter(), stats::filter()
✖ dplyr::lag() masks stats::lag()
ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
Economy Economy.Code ISO.Code Region
Length:190 Length:190 Length:190 Length:190
Class :character Class :character Class :character Class :character
Mode :character Mode :character Mode :character Mode :character
Income.Group Report.Year WBL.INDEX MOBILITY
Length:190 Min. :2018 Min. : 26.90 Min. : 0.00
Class :character 1st Qu.:2018 1st Qu.: 62.65 1st Qu.: 75.00
Mode :character Median :2018 Median : 77.50 Median :100.00
Mean :2018 Mean : 73.71 Mean : 86.18
3rd Qu.:2018 3rd Qu.: 86.90 3rd Qu.:100.00
Max. :2018 Max. :100.00 Max. :100.00
Can.a.woman.choose.where.to.live.in.the.same.way.as.a.man.
Length:190
Class :character
Mode :character
Can.a.woman.travel.outside.her.home.in.the.same.way.as.a.man.
Length:190
Class :character
Mode :character
Can.a.woman.apply.for.a.passport.in.the.same.way.as.a.man.
Length:190
Class :character
Mode :character
Can.a.woman.travel.outside.the.country.in.the.same.way.as.a.man.
Length:190
Class :character
Mode :character
WORKPLACE Can.a.woman.get.a.job.in.the.same.way.as.a.man.
Min. : 0.00 Length:190
1st Qu.: 50.00 Class :character
Median :100.00 Mode :character
Mean : 75.66
3rd Qu.:100.00
Max. :100.00
Does.the.law.prohibit.discrimination.in.employment.based.on.gender.
Length:190
Class :character
Mode :character
Is.there.legislation.on.sexual.harassment.in.employment.
Length:190
Class :character
Mode :character
Are.there.criminal.penalties.or.civil.remedies.for.sexual.harassment.in.employment.
Length:190
Class :character
Mode :character
PAY
Min. : 0.00
1st Qu.: 50.00
Median : 75.00
Mean : 63.29
3rd Qu.:100.00
Max. :100.00
Does.the.law.mandate.equal.remuneration.for.work.of.equal.value.
Length:190
Class :character
Mode :character
Can.a.woman.work.at.night.in.the.same.way.as.a.man.
Length:190
Class :character
Mode :character
Can.a.woman.work.in.a.job.deemed.dangerous.in.the.same.way.as.a.man.
Length:190
Class :character
Mode :character
Can.a.woman.work.in.an.industrial.job.in.the.same.way.as.a.man.
Length:190
Class :character
Mode :character
MARRIAGE
Min. : 0.00
1st Qu.: 60.00
Median : 80.00
Mean : 77.16
3rd Qu.:100.00
Max. :100.00
Is.the.law.free.of.legal.provisions.that.require.a.married.woman.to.obey.her.husband.
Length:190
Class :character
Mode :character
Can.a.woman.be.head.of.household.in.the.same.way.as.a.man.
Length:190
Class :character
Mode :character
Is.there.legislation.specifically.addressing.domestic.violence.
Length:190
Class :character
Mode :character
Can.a.woman.obtain.a.judgment.of.divorce.in.the.same.way.as.a.man.
Length:190
Class :character
Mode :character
Does.a.woman.have.the.same.rights.to.remarry.as.a.man. PARENTHOOD
Length:190 Min. : 0.00
Class :character 1st Qu.: 20.00
Mode :character Median : 60.00
Mean : 51.58
3rd Qu.: 80.00
Max. :100.00
Is.paid.leave.of.at.least.14.weeks.available.to.mothers.
Length:190
Class :character
Mode :character
Length.of.paid.maternity.leave
Min. : 0.0
1st Qu.: 84.0
Median : 98.0
Mean :101.9
3rd Qu.:112.0
Max. :635.0
Does.the.government.administer.100.percent.of.maternity.leave.benefits.
Length:190
Class :character
Mode :character
Is.there.paid.leave.available.to.fathers. Length.of.paid.paternity.leave
Length:190 Min. : 0.000
Class :character 1st Qu.: 0.000
Mode :character Median : 0.500
Mean : 4.584
3rd Qu.: 4.750
Max. :90.000
Is.there.paid.parental.leave. Shared.days Days.for.the.mother
Length:190 Min. : 0.00 Min. : 0.00
Class :character 1st Qu.: 0.00 1st Qu.: 0.00
Mode :character Median : 0.00 Median : 0.00
Mean : 67.85 Mean : 12.72
3rd Qu.: 0.00 3rd Qu.: 0.00
Max. :1095.00 Max. :478.00
Days.for.the.father Is.dismissal.of.pregnant.workers.prohibited.
Min. : 0.00 Length:190
1st Qu.: 0.00 Class :character
Median : 0.00 Mode :character
Mean : 10.26
3rd Qu.: 0.00
Max. :365.00
ENTREPRENEURSHIP
Min. : 0.00
1st Qu.: 75.00
Median : 75.00
Mean : 82.89
3rd Qu.:100.00
Max. :100.00
Does.the.law.prohibit.discrimination.in.access.to.credit.based.on.gender.
Length:190
Class :character
Mode :character
Can.a.woman.sign.a.contract.in.the.same.way.as.a.man.
Length:190
Class :character
Mode :character
Can.a.woman.register.a.business.in.the.same.way.as.a.man.
Length:190
Class :character
Mode :character
Can.a.woman.open.a.bank.account.in.the.same.way.as.a.man. ASSETS
Length:190 Min. : 0.00
Class :character 1st Qu.: 60.00
Mode :character Median :100.00
Mean : 80.32
3rd Qu.:100.00
Max. :100.00
Do.women.and.men.have.equal.ownership.rights.to.immovable.property.
Length:190
Class :character
Mode :character
Do.sons.and.daughters.have.equal.rights.to.inherit.assets.from.their.parents.
Length:190
Class :character
Mode :character
Do.male.and.female.surviving.spouses.have.equal.rights.to.inherit.assets.
Length:190
Class :character
Mode :character
Does.the.law.grant.spouses.equal.administrative.authority.over.assets.during.marriage.
Length:190
Class :character
Mode :character
Does.the.law.provide.for.the.valuation.of.nonmonetary.contributions.
Length:190
Class :character
Mode :character
PENSION
Min. : 25.0
1st Qu.: 50.0
Median : 75.0
Mean : 72.5
3rd Qu.:100.0
Max. :100.0
Is.the.age.at.which.women.and.men.can.retire.with.full.pension.benefits.the.same.
Length:190
Class :character
Mode :character
Is.the.age.at.which.women.and.men.can.retire.with.partial.pension.benefits.the.same.
Length:190
Class :character
Mode :character
Is.the.mandatory.retirement.age.for.women.and.men.the.same.
Length:190
Class :character
Mode :character
Are.periods.of.absence.due.to.childcare.accounted.for.in.pension.benefits.
Length:190
Class :character
Mode :character
match X Country.Code Foreign_direct_investment
Mode :logical Min. : 2.0 Length:190 Min. :-117.370
FALSE:1 1st Qu.: 60.0 Class :character 1st Qu.: 1.260
TRUE :189 Median :129.0 Mode :character Median : 2.680
Mean :131.5 Mean : 2.539
3rd Qu.:200.0 3rd Qu.: 4.240
Max. :265.0 Max. : 29.210
NA's :1 NA's :1
agriculture_forestry_value_added GNI.per.capita
Min. :-65.960 Min. : 240
1st Qu.: -1.230 1st Qu.: 1980
Median : 2.780 Median : 5700
Mean : 1.666 Mean :13684
3rd Qu.: 5.530 3rd Qu.:17330
Max. : 37.660 Max. :82470
NA's :1 NA's :1
net_barter_terms_of_trade_index gdp_per_person_employed
Min. : 53.54 Min. : 2169
1st Qu.: 97.39 1st Qu.: 16974
Median :101.00 Median : 39836
Mean :103.13 Mean : 53378
3rd Qu.:106.95 3rd Qu.: 79411
Max. :136.92 Max. :280172
NA's :1
# look up table for region abbreviationsregion_labels <-c("East Asia & Pacific"="EAP","Europe & Central Asia"="ECA","High income: OECD"="HIC","Latin America & Caribbean"="LAC","Middle East & North Africa"="MENA","South Asia"="SA","Sub-Saharan Africa"="SSA")# summary stats for gdp datagdp_summary <- df %>%group_by(Region) %>%summarise(Mean_GDP_Score =mean(gdp_per_person_employed, na.rm =TRUE),Median_GDP_Score =median(gdp_per_person_employed, na.rm =TRUE),SD_GDP_Score =sd(gdp_per_person_employed, na.rm =TRUE) )gdp_summary
# A tibble: 7 × 4
Region Mean_GDP_Score Median_GDP_Score SD_GDP_Score
<chr> <dbl> <dbl> <dbl>
1 East Asia & Pacific 45222. 23073. 51266.
2 Europe & Central Asia 52027. 51231. 23048.
3 High income: OECD 114705. 109444. 41572.
4 Latin America & Caribbean 47416. 39721. 27638.
5 Middle East & North Africa 64449. 58770. 35726.
6 South Asia 25070. 20069. 11615.
7 Sub-Saharan Africa 18788. 10542. 21457.
# summary stats for gdp datagni_summary <- df %>%group_by(Region) %>%summarise(Mean_GNI_Score =mean(GNI.per.capita, na.rm =TRUE),Median_GNI_Score =median(GNI.per.capita, na.rm =TRUE),SD_GNI_Score =sd(GNI.per.capita, na.rm =TRUE) )gni_summary
# A tibble: 7 × 4
Region Mean_GNI_Score Median_GNI_Score SD_GNI_Score
<chr> <dbl> <dbl> <dbl>
1 East Asia & Pacific 10543 3850 14924.
2 Europe & Central Asia 8633. 5730 9195.
3 High income: OECD 41262. 41725 20340.
4 Latin America & Caribbean 9874. 7890 6624.
5 Middle East & North Africa 14144. 4830 16133.
6 South Asia 3078. 2000 2995.
7 Sub-Saharan Africa 2244. 1075 3176.
# A tibble: 7 × 4
Region Mean_wbl_Score Median_wbl_Score SD_wbl_Score
<chr> <dbl> <dbl> <dbl>
1 East Asia & Pacific 70.1 75 12.6
2 Europe & Central Asia 82.4 82.5 7.96
3 High income: OECD 94.1 96.9 6.38
4 Latin America & Caribbean 79.0 80.6 9.44
5 Middle East & North Africa 44.0 37.8 16.8
6 South Asia 59.2 59.4 13.1
7 Sub-Saharan Africa 68.3 70 13.8
ggplot(df, aes(x = Region)) +geom_bar(stat ="count", fill ="skyblue") +geom_text(aes(label = ..count..), stat ="count", vjust =-0.5) +labs(title ="Distribution of Regions within Data",x ="Region",y ="Count" ) +theme(plot.title =element_text(hjust =0.5), axis.text.x =element_text(angle =45, hjust =1))
Warning: The dot-dot notation (`..count..`) was deprecated in ggplot2 3.4.0.
ℹ Please use `after_stat(count)` instead.
# A tibble: 7 × 4
Region Mean_Mobility_Score Median_Mobility_Score SD_Mobility_Score
<chr> <dbl> <dbl> <dbl>
1 East Asia & Pacif… 89 100 16.3
2 Europe & Central … 98.9 100 5.21
3 High income: OECD 100 100 0
4 Latin America & C… 90.6 100 13.8
5 Middle East & Nor… 46.2 37.5 39.1
6 South Asia 90.6 100 18.6
7 Sub-Saharan Africa 81.8 87.5 22.3
ggplot(df, aes(x = Region, y = WBL.INDEX)) +geom_bar(stat ="identity", fill ="skyblue") +labs(title ="Distribution of WBL Score",x ="Region",y ="WBL" ) +theme(plot.title =element_text(hjust =0.5), axis.text.x =element_text(angle =45, hjust =1))
## distribution of gdp scores# histogramggplot(df, aes(x = gdp_per_person_employed, fill = Region)) +geom_density(alpha =0.5) +theme_minimal() +labs(title ="Distribution of GDP by Region",x ="GDP",y ="Frequency" ) +scale_x_continuous(breaks =seq(0, 10000000, by =50000)) +theme_minimal()
Warning: Removed 1 row containing non-finite outside the scale range
(`stat_density()`).
ggplot(df, aes(x = WBL.INDEX, fill = Region)) +geom_histogram(binwidth =20) +theme_minimal() +labs(title ="Distribution of WBL Scores by Region",x ="WBL Score",y ="Frequency" ) +scale_x_continuous(breaks =seq(0, 100, by =20)) +theme_minimal()
# A tibble: 7 × 2
# Groups: Region [7]
Region n
<chr> <int>
1 East Asia & Pacific 18
2 Europe & Central Asia 10
3 High income: OECD 2
4 Latin America & Caribbean 15
5 Middle East & North Africa 19
6 South Asia 8
7 Sub-Saharan Africa 39
# A tibble: 6 × 2
# Groups: Region [6]
Region n
<chr> <int>
1 East Asia & Pacific 7
2 Europe & Central Asia 13
3 High income: OECD 32
4 Latin America & Caribbean 17
5 Middle East & North Africa 1
6 Sub-Saharan Africa 9
threshold_score <-80count_over_threshold_region <- df %>%filter(WBL.INDEX >= threshold_score) %>%filter(Region =="Middle East & North Africa")count_over_threshold_region
# A tibble: 45 × 5
Region Indicator Response Count Proportion
<chr> <chr> <chr> <int> <dbl>
1 East Asia & Pacific Can.a.woman.apply.for.a.pass… No 6 0.00789
2 East Asia & Pacific Can.a.woman.apply.for.a.pass… Yes 19 0.025
3 East Asia & Pacific Can.a.woman.choose.where.to.… No 3 0.00395
4 East Asia & Pacific Can.a.woman.choose.where.to.… Yes 22 0.0289
5 East Asia & Pacific Can.a.woman.travel.outside.h… No 2 0.00263
6 East Asia & Pacific Can.a.woman.travel.outside.h… Yes 23 0.0303
7 East Asia & Pacific Can.a.woman.travel.outside.t… Yes 25 0.0329
8 Europe & Central Asia Can.a.woman.apply.for.a.pass… No 1 0.00132
9 Europe & Central Asia Can.a.woman.apply.for.a.pass… Yes 22 0.0289
10 Europe & Central Asia Can.a.woman.choose.where.to.… Yes 23 0.0303
# ℹ 35 more rows
# look up table for mobility indicatorsmobility_labels <-c("Can.a.woman.choose.where.to.live.in.the.same.way.as.a.man."="Choice of Living Situation", "Can.a.woman.travel.outside.her.home.in.the.same.way.as.a.man."="Travel Outside Home", "Can.a.woman.apply.for.a.passport.in.the.same.way.as.a.man."="Passport Acquisition", "Can.a.woman.travel.outside.the.country.in.the.same.way.as.a.man."="Intercontinental Travel")# visualize proportionsggplot(mobility_proportions, aes(x = Region, y = Proportion, fill = Response)) +geom_bar(stat ="identity", position ="fill") +facet_wrap(~Indicator, scales ="free", labeller =labeller(Indicator = mobility_labels)) +scale_x_discrete(labels = region_labels) +theme(axis.text.x =element_text(angle =45, hjust =1)) +labs(title ="Proportions of Yes/No Responses for Mobility Indicators By Region",x ="Region", y ="Proportion" )
mob_plt_1 <-ggplot(df, aes(x = Can.a.woman.choose.where.to.live.in.the.same.way.as.a.man., fill = Region)) +geom_bar(position ="dodge") +# 'dodge' puts bars side by sidelabs(title ="Can a woman choose where to live in the same way as a man by Region", x ="Can a woman choose where to live in the same way as a man", y ="Count") +theme_minimal()ggplotly(mob_plt_1)
mob_plt_2 <-ggplot(df, aes(x = Can.a.woman.travel.outside.her.home.in.the.same.way.as.a.man., fill = Region)) +geom_bar(position ="dodge") +# 'dodge' puts bars side by sidelabs(title ="Can a woman travel outside her home in the same way as a man", x ="Can a woman travel outside her home in the same way as a man", y ="Count") +theme_minimal()ggplotly(mob_plt_2)
mob_plt_3 <-ggplot(df, aes(x = Can.a.woman.apply.for.a.passport.in.the.same.way.as.a.man., fill = Region)) +geom_bar(position ="dodge") +# 'dodge' puts bars side by sidelabs(title ="Can a woman apply for a passport in the same way as a man", x ="Can a woman apply for a passport in the same was as a man", y ="Count") +theme_minimal()ggplotly(mob_plt_3)
mob_plt_4 <-ggplot(df, aes(x = Can.a.woman.travel.outside.the.country.in.the.same.way.as.a.man., fill = Region)) +geom_bar(position ="dodge") +# 'dodge' puts bars side by sidelabs(title ="Can a woman travel outside the country in the same way as a man?", x ="Can a woman travel outside the country in the same way as a man?", y ="Count") +theme_minimal()ggplotly(mob_plt_4)
# Welch Two Sample t-testt_test_result <-t.test(MOBILITY ~ Can.a.woman.choose.where.to.live.in.the.same.way.as.a.man., data = df)print(t_test_result)
Welch Two Sample t-test
data: MOBILITY by Can.a.woman.choose.where.to.live.in.the.same.way.as.a.man.
t = -11.11, df = 38.442, p-value = 1.449e-13
alternative hypothesis: true difference in means between group No and group Yes is not equal to 0
95 percent confidence interval:
-58.07865 -40.18138
sample estimates:
mean in group No mean in group Yes
46.62162 95.75163
# Welch Two Sample t-testt_test_result <-t.test(MOBILITY ~ Can.a.woman.travel.outside.her.home.in.the.same.way.as.a.man., data = df)print(t_test_result)
Welch Two Sample t-test
data: MOBILITY by Can.a.woman.travel.outside.her.home.in.the.same.way.as.a.man.
t = -12.536, df = 17.37, p-value = 3.921e-10
alternative hypothesis: true difference in means between group No and group Yes is not equal to 0
95 percent confidence interval:
-78.48727 -55.90579
sample estimates:
mean in group No mean in group Yes
25.00000 92.19653
# Welch Two Sample t-testt_test_result <-t.test(MOBILITY ~ Can.a.woman.apply.for.a.passport.in.the.same.way.as.a.man., data = df)print(t_test_result)
Welch Two Sample t-test
data: MOBILITY by Can.a.woman.apply.for.a.passport.in.the.same.way.as.a.man.
t = -8.5657, df = 48.039, p-value = 3.098e-11
alternative hypothesis: true difference in means between group No and group Yes is not equal to 0
95 percent confidence interval:
-46.41090 -28.76507
sample estimates:
mean in group No mean in group Yes
56.70732 94.29530
# Welch Two Sample t-testt_test_result <-t.test(MOBILITY ~ Can.a.woman.travel.outside.the.country.in.the.same.way.as.a.man., data = df)print(t_test_result)
Welch Two Sample t-test
data: MOBILITY by Can.a.woman.travel.outside.the.country.in.the.same.way.as.a.man.
t = -18.855, df = 10.716, p-value = 1.46e-09
alternative hypothesis: true difference in means between group No and group Yes is not equal to 0
95 percent confidence interval:
-89.83431 -70.99902
sample estimates:
mean in group No mean in group Yes
10.00000 90.41667
# scatter plot for Mobility score vs gpd per person employedreg_mob <-ggplot(df, aes(x = MOBILITY, y = gdp_per_person_employed)) +geom_point() +geom_smooth(method ="lm", color ="red") +theme_minimal() +labs(title ="Mobility Score vs GDP per Person Employed",x ="Mobility Score", y ="GDP per Person Employed" )ggplotly(reg_mob)
`geom_smooth()` using formula = 'y ~ x'
Warning: Removed 1 row containing non-finite outside the scale range
(`stat_smooth()`).
# density plotggplot(df, aes(x = MOBILITY)) +geom_density(fill ="skyblue", alpha =0.5, color ="black") +geom_vline(aes(xintercept =mean(MOBILITY, na.rm =TRUE)), color ="red", linetype ="dashed", linewidth =1) +geom_vline(aes(xintercept =median(MOBILITY, na.rm =TRUE)), color ="blue", linetype ="dashed", linewidth =1) +theme_minimal() +labs(title ="Density of Mobility Score", x ="Mobility Score", y ="Density") +annotate("text", x =mean(df$MOBILITY, na.rm =TRUE), y =0.015, label ="Mean", color ="red", angle =90, vjust =1.5) +annotate("text", x =median(df$MOBILITY, na.rm =TRUE), y =0.012, label ="Median", color ="blue", angle =90, vjust =1.5)